package com.aidong.home.controller;

import com.aidong.home.controller.concern.Success;
import com.aidong.home.service.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by john on 17-4-21.
 */
@RestController("sysHome")
@RequestMapping("/home")
public class HomeController {

    @Autowired
    HomeService homeService;

    @RequestMapping("")
    public Success index(@RequestParam(value = "cityId", defaultValue = "1211000000") int cityId) {
        return homeService.home(cityId);
    }

    @RequestMapping("course/{code}")
    public Success course(@RequestParam(value = "cityId", defaultValue = "1211000000") int cityId,
                          @PathVariable("code") int code,
                          @RequestParam(value = "page", defaultValue = "0") int page) {
        return homeService.courseVideo(cityId, code, page);
    }

    @RequestMapping("course/{code}/relation")
    public Success relation(@RequestParam(value = "cityId", defaultValue = "1211000000") int cityId,
                            @PathVariable("code") int code,
                            @RequestParam("id") int currentId) {
        return homeService.relation(cityId, code, currentId);
    }
}
